local wen__yubao = fk.CreateSkill {
  name = "wen__yubao",
}

Fk:loadTranslationTable{
  ["wen__yubao"] = "预报", 
  [":wen__yubao"] = "准备阶段，你可以观看牌堆顶的牌，且你可以将此牌当【无中生有】使用，然后若你的手牌数为全场最大，你受到1点雷电伤害。",
  ["#wen__yubao"] = "预报：观看牌堆顶的牌，且你可以将此牌当【无中生有】使用，然后若你的手牌数为全场最大，你受到1点雷电伤害",
  ["wen__yubao1"] = "将%arg当【无中生有】使用",
  ["#wen__yubao-use"] = "预报：将%arg当【无中生有】使用",
}

wen__yubao:addEffect(fk.EventPhaseStart, {
    prompt = "#wen__yubao",
    card_filter = Util.FalseFunc,
    target_filter = Util.FalseFunc,

    can_trigger = function(self, event, target, player, data)
      return target == player 
      and player:hasSkill(wen__yubao.name) 
      and player.phase == Player.Start
    end,
  
    on_use = function(self, event, target, player, data)
    local room = player.room  -- 获取房间对象

    local cards = room:getNCards(1)
    local card = Fk:getCardById(cards[1])
    
    local ex_nihilo = Fk:cloneCard("ex_nihilo")
    ex_nihilo.skillName = wen__yubao.name
    ex_nihilo:addSubcard(card)

    local choices = {}
    table.insert(choices, "wen__yubao1:::"..card:toLogString())
    table.insert(choices, "Cancel")

    local choice = room:askToViewCardsAndChoice(player, {
      cards = cards,
      choices = choices,
      skill_name = wen__yubao.name
    })
    if choice == "Cancel" then return end
    if choice:startsWith("wen__yubao1") then
      room:askToUseVirtualCard(player, {
        name = "ex_nihilo",
        subcards = cards,
        skill_name = wen__yubao.name,
        prompt = "#wen__yubao-use:::"..card:toLogString(),
        cancelable = false,
      })
      if table.every(player.room:getOtherPlayers(player), function (p)
        return p:getHandcardNum() <= player:getHandcardNum()   
      end)
      then room:damage({
        from = player,
        to = player,
        damage = 1,
        damageType = fk.ThunderDamage,
        skillName = wen__yubao.name,
      })
      end
    end  
  end,
})

return wen__yubao